
import java.math.BigInteger;
import java.util.Scanner;

public class C_1_13_6 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String newStr = str + str;
        int i = 0;
        int len = str.length();
        BigInteger bd = new BigInteger(str);
        for (i = 2; i <= len; i++) {
            BigInteger newTmp = bd.multiply(BigInteger.valueOf(i));
            if(newStr.lastIndexOf(newTmp.toString())<0){
                System.out.print(0);
                System.exit(0);
            }
        }
        System.out.print(1);
    }
}